using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Matching : MonoBehaviour
{
    public bool[] following = new bool[20];
    public DialogueManager[] Characters;

    private void Start()
    {
        for (int i = 0; i < following.Length; i++)
        {
            following[i] = false;
        }
    }

    public void subscribeFollow(int id)
    {
        bool[] m = Characters[id].dialogueData.matches;
        following[id] = true;

        for (int i = 0; i < m.Length; i++)
        {
            if (m[i] == true && i != id)
            {
                if (following[i] == true)
                {
                    Characters[id].match();
                    Characters[i].match();
                    Debug.Log("Matched" + Characters[id].dialogueData.name + "and" + Characters[i].dialogueData.name);
                    following[id] = false;
                    following[i] = false;
                }
            }
        }
        
        
    }
    
    public void unsubscribeFollow(int id)
    {
        following[id] = false;
    }

}
